const db = require("../../middleware/db");
const Sequelize = require("sequelize");

module.exports = sys_model_field = db.define("sys_model_field", {
  model_id: {
    type: Sequelize.INTEGER(11).UNSIGNED,
    allowNull: false,
    defaultValue: "0",
  },

  key: {
    type: Sequelize.STRING(50),
    allowNull: false,
    defaultValue: "",
  },
  name: {
    type: Sequelize.STRING(50),
    allowNull: false,
    defaultValue: 0,
  },
  // 控件
  control: {
    type: Sequelize.TEXT,
    allowNull: false,
    defaultValue: "{}",
  },
  // 排序
  sort: {
    type: Sequelize.INTEGER(11),
    allowNull: false,
    defaultValue: 1,
  },
  // 类型
  data_type: {
    type: Sequelize.STRING(50),
    allowNull: false,
    defaultValue: "0",
  },

  //数据长度
  data_length: {
    type: Sequelize.INTEGER(11),
    allowNull: false,
    defaultValue: 50,
  },

  //是否为空 0 为空 ， 1 不允许为空
  allow_null: {
    type: Sequelize.INTEGER(1),
    allowNull: false,
    defaultValue: 0,
  },

  // 默认值
  default_value: {
    type: Sequelize.STRING(50),
    allowNull: false,
    defaultValue: "",
  },
});

//sys_model_field.sync({ force: true });
